package com.isunland.managesystem.ui;

import android.os.Bundle;
import com.google.gson.Gson;
import com.isunland.managesystem.R;
import com.isunland.managesystem.adapter.ScoreMsgListAdapter;
import com.isunland.managesystem.base.Base;
import com.isunland.managesystem.base.BaseListFragment;
import com.isunland.managesystem.common.ApiConst;
import com.isunland.managesystem.entity.ScoreMsgOriginal;
import com.isunland.managesystem.utils.ParamsNotEmpty;
import com.isunland.managesystem.utils.ToastUtil;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: HuXiaoDan
 * 创建时间: 2017/7/13 15:43
 */
public class ScoreMsgListFragment extends BaseListFragment {

  private ArrayList<String> rows;

  @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setBack(true);
    setTitleCustom(R.string.approveTitle);
    rows = new ArrayList<>();
  }

  @Override public String getUrl() {
    return ApiConst.URL_SCORE_MSG_LIST;
  }

  @Override public HashMap<String, String> getparameters() {
    ParamsNotEmpty params = new ParamsNotEmpty();
    params.put("id", mBaseParams.getId());
    return params.getParams();
  }

  @Override public void resolveResponse(String json) {
    ScoreMsgOriginal original = new Gson().fromJson(json, ScoreMsgOriginal.class);
    if (original != null && Base.SUCCESS == original.getResult()) {
      rows.clear();
      rows.addAll(original.getRows());
      ScoreMsgListAdapter mAdapter = new ScoreMsgListAdapter(mActivity, rows);
      setListAdapter(mAdapter);
    } else {
      ToastUtil.show("获取数据失败");
    }
  }
}
